{template header}

<div class="with_side w960">
	<div class="main">
		<h2>{lang text admincenter}</h2><br />
		<!--{if ($adminid == 1)}-->
			<!--{if ($action == 'calculate')}-->
				<form method="post" action="admin.php">
					<input type="submit" value="{lang button calculate}" name="calculate" />
				</form>
			<!--{elseif ($action == 'settings')}-->
				<form method="post" action="admin.php">
					<input type="hidden" name="formhash" value="{FORMHASH}" />
					{lang text contestname}: <input type="text" value="{$contestname}" name="config[contestname]" onchange="SendData(this.value, 'contestname', 'contestnamealert')" /><span id="contestnamealert"></span><br />
					{lang text starttime}: <input type="text" value="{$starttime['string']}" name="config[starttime]" onchange="SendData(this.value, 'time', 'starttimealert')" /><span id="starttimealert"></span><br />
					{lang text endtime}: <input type="text" value="{$endtime['string']}" name="config[endtime]" onchange="SendData(this.value, 'time', 'endtimealert')" /><span id="endtimealert"></span><br />
					{lang text introduction}: <br />
					<textarea name="config[introduction]" rows="10" cols="75">{$introduction}</textarea><br />
					<input type="submit" value="{lang button settings}" name="settings" />
				</form>
			<!--{elseif ($action == 'edit')}-->
				<form method="post" action="admin.php?action=edit&pid={$_GET['pid']}">
					<input type="hidden" name="formhash" value="{FORMHASH}" />
					<input type="hidden" value="{$problem['type']}" name="ptype" id="ptype" />
					<input type="hidden" value="{$_GET['pid']}" name="pid" id="pid" />
					{lang text problembody}: <br /><textarea name="problem" cols="40" rows="5">{$problem['problem']['problem']}</textarea><br />
					{lang text problemscore}: <input type="text" name="score" value="{$problem['score']}" /><span id="scorealert"></span><br />
					{lang text problemlevel}: <input type="text" name="level" value="{$problem['level']}" />
					<div id="problembody">
					<!--{if ($problem['type'] == 1)}-->
						<div id="blankbody">
							{lang text answer}: <input type="text" name="blankanswer" value="{$problem['problem']['answer']}" /><br />
							{lang text judge}: <input type="text" name="blankjudge" value="{$problem['problem']['judge']}" /><br />
							{lang text manual}: <!--{if ($problem['manual'])}--><input type="checkbox" name="manual" value="1" checked="checked" /><!--{else}--><input type="checkbox" name="manual" value="1" /><!--{/if}--><br />
						</div>
					<!--{elseif ($problem['type'] == 2)}-->
						<div id="choicebody">
							{lang text option}: <br /><textarea id="choice" name="choice" cols="40" rows="5" onchange="makenewoptions();"><!--{loop $problem['problem']['choice'] $choice}-->{$choice['string']}<!--{/loop}--></textarea><br />
							{lang text answer}: <select id="answer" name="choiceanswer">
							<!--{loop $problem['problem']['choice'] $choice}-->
								<!--{if ($choice['value'] == $problem['problem']['answer'])}-->
								<option value="{$choice['value']}" selected="selected">{$choice['string']}</option>
								<!--{else}-->
								<option value="{$choice['value']}">{$choice['string']}</option>
								<!--{/if}-->
							<!--{/loop}-->
							</select><br />
						</div>
					<!--{elseif ($problem['type'] == 3)}-->
						<div id="mchoicebody">
							{lang text option}: <br /><textarea id="mchoice" name="mchoice" cols="40" rows="5" onchange="mmakenewoptions();"><!--{loop $problem['problem']['choice'] $choice}-->{$choice['string']}<!--{/loop}--></textarea><br />
							{lang text answer}: <br /><select id="manswer" multiple="multiple" name="mchoiceanswer[]">
							<!--{loop $problem['problem']['choice'] $choice}-->
								<!--{if ($choice['value'] & (int)$problem['problem']['answer'])}-->
								<option value="{$choice['value']}" selected="selected">{$choice['string']}</option>
								<!--{else}-->
								<option value="{$choice['value']}">{$choice['string']}</option>
								<!--{/if}-->
							<!--{/loop}-->
							</select><br />
						</div>
					<!--{else}-->
						<div id="essaybody">
							{lang text answer}: <br /><textarea name="essayanswer" cols="40" rows="5">{$problem['problem']['answer']}</textarea><br />
						</div>
					<!--{/if}-->
					</div>
					<input type="submit" id="editsubmit" value="{lang button submit}" name="edit" />
				</form>
			<!--{elseif ($action == 'add')}-->
				<input name="chooseblank" type="button" value="{lang text blank}" onclick="show('problembody', 'div', 0);$('#ptype')[0].value='1';"/>
				<input name="choosechoice" type="button" value="{lang text choice}" onclick="show('problembody', 'div', 1);$('#ptype')[0].value='2';"/>
				<input name="choosemchoice" type="button" value="{lang text mchoice}" onclick="show('problembody', 'div', 2);$('#ptype')[0].value='3';"/>
				<input name="chooseessay" type="button" value="{lang text essay}" onclick="show('problembody', 'div', 3);$('#ptype')[0].value='4';"/>
				<form method="post" action="admin.php?action=add">
					<input type="hidden" name="formhash" value="{FORMHASH}" />
					<input type="hidden" value="1" name="ptype" id="ptype" />
					{lang text problembody}: <br /><textarea name="problem" cols="40" rows="5"></textarea><br />
					{lang text problemscore}: <input type="text" name="score" value="" /><span id="scorealert"></span><br />
					{lang text problemlevel}: <input type="text" name="level" value="" />
					<div id="problembody">
						<div id="blankbody">
							{lang text answer}: <input type="text" name="blankanswer" value="" /><br />
							{lang text judge}: <input type="text" name="blankjudge" value="" /><br />
							{lang text manual}: <input type="checkbox" name="manual" value="1" /><br />
						</div>
						<div id="choicebody" style="display:none;">
							{lang text option}: <br /><textarea id="choice" name="choice" cols="40" rows="5" onchange="makenewoptions();"></textarea><br />
							{lang text answer}: <select id="answer" name="choiceanswer"><option value="0"></option></select><br />
						</div>
						<div id="mchoicebody" style="display:none;">
							{lang text option}: <br /><textarea id="mchoice" name="mchoice" cols="40" rows="5" onchange="mmakenewoptions();"></textarea><br />
							{lang text answer}: <br /><select id="manswer" multiple="multiple" name="mchoiceanswer[]"><option value="0"></option></select><br />
						</div>
						<div id="essaybody" style="display:none;">
							{lang text answer}: <br /><textarea name="essayanswer" cols="40" rows="5"></textarea><br />
						</div>
					</div>
					<input type="submit" value="{lang button submit}" name="add" />
				</form>
			<!--{elseif ($action == 'list')}-->
				<!--{loop $problem $p}-->
				<div class="problem">
					<a href="admin.php?action=edit&pid={$p['id']}">({lang text edit})</a><a href="admin.php?action=delete&pid={$p['id']}">({lang text delete})</a>
					{$p['problem']['problem']}<br />
					<!--{if ($p['type'] == 1)}-->
						<br />
					<!--{elseif ($p['type'] == 2)}-->
						<!--{loop $p['problem']['choice'] $choice}-->
							{$choice['string']}<br />
						<!--{/loop}-->
					<!--{elseif ($p['type'] == 3)}-->
						<!--{loop $p['problem']['choice'] $choice}-->
							{$choice['string']}<br />
						<!--{/loop}-->
					<!--{else}-->
						<br />
					<!--{/if}-->
				</div>
				<!--{/loop}-->
			<!--{elseif ($action == 'judge')}-->
				<!--{loop $recordset $record}-->
				<form action="admin.php?action=judge" method="post">
					<input type="hidden" name="formhash" value="{FORMHASH}" />
					{$record['problem']['problem']}<br />
					{$record['problem']['answer']}({lang general score}:{$record['score']})<br />
					{$record['event']}<br />
					<input type="hidden" name="rid" value="{$record['id']}" />
					<input type="text" name="judgescore" />
					<input type="submit" name="judge" />
				</form>
				<!--{/loop}-->
			<!--{elseif ($action == 'announce')}-->
				<form method="post" action="admin.php?action=announce">
					<input type="hidden" name="formhash" value="{FORMHASH}" />
					<select name="announcementtype">
						<option value="notice">{lang text notice}</option>
						<option value="warning">{lang text warning}</option>
					</select>
					UID: <input type="text" name="submituid" value="" /><br />
					<input type="text" style="width: 500px;" name="announcement" value="" /><br />
					<input type="submit" value="{lang button submit}" name="submitannouncement" />
				</form>
			<!--{elseif ($action == 'userlist')}-->
				<h2>{lang text userlist}</h2>
				<!--{loop $userlist $user}-->
					UID: {$user['id']}: {$user['username']} {$user['realname']} <br />
				<!--{/loop}-->
			<!--{else}-->
				{lang admincenter_welcome}<br /><br />
				<!--{loop $clarifications $clarification}-->
				<form method="post" action="admin.php">
					<input type="hidden" name="formhash" value="{FORMHASH}" />
					<input type="hidden" name="inputuid" value="{$clarification['uid']}" />
					<input type="hidden" name="inputcid" value="{$clarification['id']}" />
					{$clarification['uid']}: {$clarification['event']} <br />
					<input type="text" name="replytext" style="width: 500px;" value="" />
					<input type="submit" name="reply" value="{lang button reply}" />
				</form>
				<!--{/loop}-->
			<!--{/if}-->
		<!--{/if}-->
	</div>
	
	<div class="side">
		{template menu}
	</div>
</div>

{template footer}